import { fineCardBind, fineCardGetCardListByUserId } from '@/services/fineCard';

/**
 * 礼品卡相关 【用户确认订单的礼品卡选择】
 */
export default {
  namespace: 'fineCard',
  state: {},
  effects: {
    // 添加礼品卡
    *fineCardBind({ payload }, { call }) {
      const res = yield call(fineCardBind, payload);
      const { code, content = {} } = res;
      if (code === '1') {
        return content;
      } else {
        // message.error(res.message);
        return Promise.reject();
      }
    },
    // 礼品卡列表
    *fineCardGetCardList({ payload }, { call }) {
      const res = yield call(fineCardGetCardListByUserId, payload);
      const { code, content = {} } = res;
      if (code === '1') {
        return content;
      } else {
        // message.error(res.message);
        return Promise.reject();
      }
    },
  },
  reducers: {},
};
